<template>
  <div>
    <!-- 子组件内容 -->
    <!-- <MyOne v-if="comp === 'MyOne'"></MyOne>
    <MyTwo v-else></MyTwo> -->

    <!-- 动态组件 -->
    <!-- <component :is="comp"></component> -->
    <component :is="comp"></component>

    <button @click="comp = 'MyOne'">1</button>
    <button @click="comp = 'MyTwo'">2</button>
  </div>
</template>

<script>
import MyOne from '@/components/MyOne.vue'
import MyTwo from '@/components/MyTwo.vue'

export default {
  components: {
    MyOne,
    MyTwo,
  },
  data() {
    return {
      comp: 'MyOne',
    }
  },
}
</script>

<style scoped></style>
